home *** CD-ROM | disk | FTP | other *** search
- # SpecTcl, by S. A. Uhler
- # Copyright (c) 1994-1995 Sun Microsystems, Inc.
- #
- # See the file "license.txt" for information on usage and redistribution
- # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- #
- # go render a page. We have to make sure we don't render one page while
- # still rendering the previous one.
-
- set Help_history ""
- proc HMlink_callback {win {file history}} {
- global Help_dir Help_history Help_message
-
- set fragment ""
- regexp {([^#]*)#(.+)} $file dummy file fragment
- if {$file == "" && $fragment != ""} {
- HMgoto $win $fragment
- return
- }
-
- if {$file == "history"} {
- if {[llength $Help_history] <2} {
- set Help_message "Already at first page"
- return
- }
- set file [lindex $Help_history 1]
- set Help_history [lrange $Help_history 1 end]
- } elseif {[lindex $Help_history 0] != $file} {
- # puts "At: [lindex [$win yview] 0]"
- set Help_history "$file $Help_history"
- }
-
- HMreset_win $win
- if {$fragment != ""} {
- HMgoto $win $fragment
- }
- if {[catch {set fd [open $Help_dir/$file r]}]} {
- set Help_message "Sorry, couldn't find help file $Help_dir/$file"
- return
- }
- HMparse_html [read $fd] "HMrender $win"
- HMset_state $win -stop 1 ;# stop rendering previous page if busy
- close $fd
- }
-
- # supply an image callback function
- # Read in an image if we don't already have one
- # callback to library for display
-
- proc HMset_image {win handle src} {
- global Help_dir Help_message
- set image $Help_dir/$src
- if {[string first " Image_$image " " [image names] "] >= 0} {
- HMgot_image $handle Image_$image
- } else {
- set Help_message "fetching image $src"
- update idletasks
- global TRANSPARENT_GIF_COLOR
- set TRANSPARENT_GIF_COLOR [$win cget -bg]
- catch {image create photo Image_$image -file $image} image
- HMgot_image $handle $image
- }
- }
-
- # Lets invent a new HTML tag, just for fun.
- # Change the color of the text. Use html tags of the form:
- # <color value=blue> ... </color>
- # We can invent a new tag for the display stack. If it starts with "T"
- # it will automatically get mapped directly to a text widget tag.
-
- proc HMtag_color {win param text} {
- upvar #0 HM$win var
- set value bad_color
- HMextract_param $param value
- $win tag configure $value -foreground $value
- HMstack $win "" "Tcolor $value"
- }
-
- proc HMtag_/color {win param text} {
- upvar #0 HM$win var
- set value bad_color
- HMstack $win / "Tcolor {}"
- }
-
- # downloading fonts can take a long time. We'll override the default
- # font-setting routine to permit better user feedback on fonts. We'll
- # keep our own list of installed fonts on the side, to guess when delays
- # are likely
-
- proc HMset_font {win tag font} {
- global Fonts Help_message
- if {![info exists Fonts($font)]} {
- set Fonts($font) 1
- set Help_message "downloading font $font"
- update idletasks
- }
- set Help_message ""
- catch {$win tag configure $tag -font $font} message
- }
-